<template>
  <el-tabs v-model="tabPaneVal" type="border-card" @tab-click="handleClick">
    <el-tab-pane label="入驻商资料" name="ShipmentEdit">
      <ShipmentEdit v-if="isShipmentEditShow" ref="ShipmentEditRef" :parent-data="parentData" />
    </el-tab-pane>
    <el-tab-pane label="开票信息管理" name="InvoiceMessage">
      <InvoiceMessage v-if="isInvoiceMessageShow" ref="InvoiceMessageRef" :parent-data="parentData" />
    </el-tab-pane>
    <el-tab-pane label="地址管理" name="CommonRouteInfo">
      <CommonRouteInfo v-if="isCommonRouteInfoShow" ref="CommonRouteInfoRef" :parent-data="parentData" />
    </el-tab-pane>
    <el-tab-pane label="承运分组" name="VehicleTeam">
      <VehicleTeam v-if="isVehicleTeamShow"  ref="VehicleTeamRef" :parent-data="parentData" />
    </el-tab-pane>
    <el-tab-pane label="合同管理" name="ShipmentContract">
      <ShipmentContract v-if="isShipmentContractShow"  ref="ShipmentContractRef" :parentData="parentData" />
    </el-tab-pane>
  </el-tabs>
</template>

<script>
import ShipmentEdit from "./components/shipmentEdit.vue";
import InvoiceMessage from "./components/invoiceMessage/invoiceMessageList.vue";
import CommonRouteInfo from "./components/commonRouteInfo/commonRouteInfoList.vue";
import VehicleTeam from "./components/vehicleTeam/vehicleTeamList.vue";
import ShipmentContract from "./components/shipmentContract/shipmentContractList.vue";
import { SelectAddress } from "@/api/orderform";
import { getListDict, getShipperList, getGoodsTypeDict } from "@/api/shipment";
import lineManagement from '@/views/basicInfo/shipment/shipmentForm/components/lineManagement/lineManagementList'
export default {
  name: "InfoShipmentForm",
  components: {
    ShipmentEdit,
    InvoiceMessage,
    CommonRouteInfo,
    VehicleTeam,
    ShipmentContract
  },
  data() {
    return {
      parentData: {
        isDetail: true,
        areaOptions: [],
        receiverUserCodeOptions: [],
        typeOptions: [],
        vehicleDictList: [],
        bankOptions: []
      },
      tabPaneVal: "ShipmentEdit",
      isShipmentEditShow: true,
      isInvoiceMessageShow: false,
      isCommonRouteInfoShow: false,
      isVehicleTeamShow: false,
      isShipmentContractShow:false
    };
  },
  created() {
    // 省市县
    SelectAddress().then(response => {
      this.parentData.areaOptions = response.data.records;
    });
    // 货物类型字典
    getGoodsTypeDict({ parentCode: "goodsBigType" }).then(response => {
      this.parentData.goodsTypeList = response.data.records;
    });
    // 开票方式、车型、开户银行
    getListDict({ types: "billingType, vehicleClassification, bank" }).then(response => {
      this.parentData.typeOptions = response.data.filter(
        item => item.type === "billingType"
      )[0]["dictList"];
      //个人入驻商，只有 0 现付开票
      this.parentData.typeOptions = this.parentData.typeOptions.filter(
          item => item.code === "0"
      )
      this.parentData.vehicleDictList = response.data.filter(
        item => item.type === "vehicleClassification"
      )[0]["dictList"];
      this.parentData.bankOptions = response.data.filter(
        item => item.type === "bank"
      )[0]["dictList"];
    });
  },
  methods: {
    handleClick(tab, event) {
      this[`is${tab.name}Show`] = true;
      this.$nextTick(() => {
        this.$refs[`${tab.name}Ref`].findList() ;
      })
    }
  }
};
</script>
